home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Games: Greatest Hits 1996
/
Amiga Games: Greatest Hits 1996.iso
/
archive
/
userbox
/
publicdomain
/
edspell.lha
/
EdSpell
/
Rexx
/
SpellBlock.epxx
< prev
next >
Wrap
Text File
|
1996-07-27
|
6KB
|
204 lines
/************************************************************************/
/* */
/* File : SpellBlock.epxx */
/* Author : Martin Reddy */
/* Version : 1.2 */
/* Date : 10/2/95 */
/* Purpose : An ARexx script used to control the text editor EdWord */
/* Note : This is part of the Spell Checking facility of EdWord */
/* Function : This script file will check the spelling for the */
/* currently selected block of text. (see below for */
/* customisation). */
/* Updates : [27/7/96] - Cleaned up ProgInd, added more error checking */
/* */
/************************************************************************/
/* Set IGNORE_VALID_ROOTS to TRUE if you want the spell check to
ignore words which aren't in the dictionary, but do have a
valid root, e.g. ignore WASTED if the word WASTE exists in the
dictionary. This reduces the need to have every tense of a
word, and plurals, to be explicitly stored in the dictionary */
IGNORE_VALID_ROOTS = TRUE
/*-------------- Nothing To Change Below Here -----------*/
HOST = ADDRESS()
ADDRESS VALUE HOST
OPTIONS RESULTS
/****** Make sure there is a block to spell check first ******/
IsSelected
IF ( RESULT == 0 ) THEN DO
Inform "No Block Has Been Currently Defined|Please Drag Select Region First."
EXIT
END
/********** Make sure that the ISpell process is up *********/
IF ~SHOW( PORTS, 'IRexxSpell' ) THEN DO
Message "Loading Dictionary..."
ADDRESS COMMAND 'run <nil: >nil: EdSpell:ISpell/ispell -r >nil: <nil:'
ADDRESS COMMAND 'EdSpell:ISpell/WaitForPort IRexxSpell'
IF RC ~= 0 THEN DO
Inform "Could Not Start ISpell Process|Spell Check Aborted!"
Message ""
EXIT
END
END
/**************** Get a Word From The User *****************/
Message "Spell Checking Block..."
SetView OFF
ProgressIndicator
GetEOLWrap; EOLSAVE=RESULT; SetEOLWrap ON
JumpToBlock
GetWord; WORD = UPPER(RESULT)
IsInBlock
DO UNTIL RESULT == 0
CALL CheckWord(WORD)
GetNextWord
IF RC ~= 0 THEN LEAVE
WORD = UPPER(RESULT)
IsInBlock
END
/**************** All done now: quit... ****************/
CALL CloseDown
Inform "End of Block Reached|Spell Check Completed."
EXIT
/************ PROCEDURE: "CloseDown" ************/
CloseDown: PROCEDURE EXPOSE EOLSAVE
SetEOLWrap EOLSAVE
ProgressIndicator
SetView ON
Message ""
RETURN
/************ PROCEDURE: "AbortSpellCheck" ************/
AbortSpellCheck: PROCEDURE
CHOICE "Do You Really Want To|Terminate This Spell Check?@@Yes, Stop|No, Continue"
IF RC == 1 THEN DO
CALL CloseDown
EXIT
END
MovePrevWord
RETURN
/************ PROCEDURE: "HighlightWord" ************/
HighlightWord: PROCEDURE
MoveRight
MovePrevWord
ProgressIndicator
SetView ON
RETURN
/************ PROCEDURE: "AddWord(word)" ************/
AddWord: PROCEDURE
PARSE ARG THEWORD
Choice "Please Confirm The Addition of|"||THEWORD||" To The Dictionary.@@Add Word|Cancel"
IF RC ~= 0 THEN DO
ADDRESS "IRexxSpell" ADD THEWORD
END
RETURN
/************** PROCEDURE: TurnOffView ****************/
TurnOffView: PROCEDURE
Message "Spell Checking Block..."
SetView OFF
ProgressIndicator
RETURN
/************ PROCEDURE: "CheckWord(word)" ************/
CheckWord: PROCEDURE EXPOSE IGNORE_VALID_ROOTS
PARSE ARG SEARCHWORD
SEARCHWORD = COMPRESS( SEARCHWORD, '~`,./<>?;:"[]{}!@#$%^&*()+|=\- ' )
IF SEARCHWORD == '' THEN RETURN
INTERACT = FALSE
ADDRESS "IRexxSpell" CHECK SEARCHWORD
WORD = RESULT
IF WORD == "*" THEN DO
RETURN
END; ELSE IF LEFT(WORD,1) == "+" THEN DO
IF IGNORE_VALID_ROOTS == TRUE THEN RETURN
CALL HighlightWord
PARSE VAR WORD DUMMY ROOT
Choice SEARCHWORD" Is A Valid Combination|But Is Not In Dictionary|(Root Word Is:"||ROOT||")@@Ignore|Stop|Add Word"
IF RC == 0 THEN DO
CALL AddWord(SEARCHWORD)
END; ELSE IF RC == 2 THEN DO
CALL AbortSpellCheck
END
CALL TurnOffView
END; ELSE IF LEFT(WORD,1) == "&" THEN DO
CALL HighlightWord
PARSE VAR WORD DUMMY SUGA SUGB SUGC SUGD SUGE
SUG = "|1) "SUGA
IF (SUGB ~= "END") & (SUGB ~= "") & (SUGB ~= "SUGB") THEN DO
SUG = SUG||"|2) "||SUGB
END
IF (SUGC ~= "END") & (SUGC ~= "") & (SUGC ~= "SUGC") THEN DO
SUG = SUG||"|3) "||SUGC
END
IF (SUGD ~= "END") & (SUGD ~= "") & (SUGD ~= "SUGD") THEN DO
SUG = SUG||"|4) "||SUGD
END
INTERACT = TRUE
PROMPT = "'"||SEARCHWORD||"' Not In Dictionary|Possible Suggestions Are:|"||SUG
END; ELSE DO
CALL HighlightWord
INTERACT = TRUE
PROMPT = "'"||SEARCHWORD||"' Not In Dictionary|No Possible Suggestions Found"
END
IF INTERACT == TRUE THEN DO
Choice PROMPT||"@@Ignore|Add/Edit|Stop"
IF RC == 0 THEN DO
CALL AbortSpellCheck
END; ELSE IF RC == 2 THEN DO
Choice "Word = '"||SEARCHWORD||"'|| Edit = Edit Current Word | Add = Add Word To Dictionary|Cancel = Continue Spell Check @@Edit|Add|Cancel"
IF RC == 1 THEN DO
GetInput "Type New Spelling For Word (Blank=Abort)"
NEWWORD = RESULT
IF NEWWORD ~= "RESULT" & NEWWORD ~= "" THEN DO
DeleteWord
InsertText D2C(34)||NEWWORD||" "||D2C(34)
MovePrevWord
END
END; ELSE IF RC == 2 THEN DO
CALL AddWord(SEARCHWORD)
END
END
CALL TurnOffView
END
RETURN